<?php

class Matchs_Model extends Model {

    function __construct() {
        parent::__construct();
    }

 
    /**
     * Print Matchs table 
     */
    function PrintMathcsTable() {
        $sth = $this->database->prepare("
            SELECT Matchs.matchId,  
                TeamAP1.username AS teamAP1Name, 
                TeamAP2.username AS teamAP2Name,
                teamAScore,  
                TeamBP1.username AS teamBP1Name, 
                TeamBP2.username AS teamBP2Name, 
                teamBScore 
            FROM Matchs 
                LEFT JOIN Members AS TeamAP1 ON Matchs.teamAPlayer1 = TeamAP1.memberId 
                LEFT JOIN Members AS TeamAP2 ON Matchs.teamAPlayer2 = TeamAP2.memberId 
                LEFT JOIN Members AS TeamBP1 ON Matchs.teamBPlayer1 = TeamBP1.memberId 
                LEFT JOIN Members AS TeamBP2 ON Matchs.teamBPlayer2 = TeamBP2.memberId 
            ORDER BY Matchs.date ASC");
        $sth->execute();

        return $sth;
    }

}
